package org.sgx.gapi.client.apis.tasks.tasks;

import org.sgx.gapi.client.GAPI;
import org.sgx.gapi.client.client.ClientRequest;
import org.sgx.gapi.client.client.ClientRequestCallback;
import org.sgx.gapi.client.client.GAPICallback;
import org.sgx.gapi.client.client.GAPIListRequest;
import org.sgx.gapi.client.client.GAPIResult;
import org.sgx.gapi.client.client.HttpRequest;
import org.sgx.jsutil.client.JsObject;

/**
 * Returns all tasks in the specified task list
 * 
 * @see https://developers.google.com/google-apps/tasks/v1/reference/tasks/list
 * @author sg
 * 
 */
public class ListRequest extends GAPIListRequest<ListResponse> {
	String tasklist, completedMax, completedMin, dueMax, dueMin, updatedMin;
	boolean showCompleted, showDeleted, showHidden;

	@Override
	public void execute(final GAPICallback<ListResponse> c) {
		JsObject param = getListParams();
		// TODO: put all params
		ClientRequest clientReq = ClientRequest.create().path("/tasks/v1/lists/" + tasklist + "/tasks").params(param);
		HttpRequest req = GAPI.get().client().request(clientReq);
		req.execute(new ClientRequestCallback() {
			@Override
			public void call(GAPIResult jsonResp, String rawResp) {
				c.call((ListResponse) jsonResp.cast());
			}
		});
	}

	public String getTasklist() {
		return tasklist;
	}

	public void setTasklist(String tasklist) {
		this.tasklist = tasklist;
	}

	public String getCompletedMax() {
		return completedMax;
	}

	public void setCompletedMax(String completedMax) {
		this.completedMax = completedMax;
	}

	public String getCompletedMin() {
		return completedMin;
	}

	public void setCompletedMin(String completedMin) {
		this.completedMin = completedMin;
	}

	public String getDueMax() {
		return dueMax;
	}

	public void setDueMax(String dueMax) {
		this.dueMax = dueMax;
	}

	public String getDueMin() {
		return dueMin;
	}

	public void setDueMin(String dueMin) {
		this.dueMin = dueMin;
	}

	public String getUpdatedMin() {
		return updatedMin;
	}

	public void setUpdatedMin(String updatedMin) {
		this.updatedMin = updatedMin;
	}

	public boolean isShowCompleted() {
		return showCompleted;
	}

	public void setShowCompleted(boolean showCompleted) {
		this.showCompleted = showCompleted;
	}

	public boolean isShowDeleted() {
		return showDeleted;
	}

	public void setShowDeleted(boolean showDeleted) {
		this.showDeleted = showDeleted;
	}

	public boolean isShowHidden() {
		return showHidden;
	}

	public void setShowHidden(boolean showHidden) {
		this.showHidden = showHidden;
	}

}
